﻿Public Class frm_DisSerVatPerBill
#Region "Khai báo biến"
    Public gvStr_Type As String
    Dim mvBol_Close As Boolean = False
    Dim mvUrc_Caculator As New urc_Calculator()
    Dim mvCls_SaleDetail As New cls_SalesDetail
    Dim mvCls_SaleDetailUpdate As New cls_SalesDetail_Update
#End Region
#Region "Hàm khởi tạo"
    Private Sub SubM_InitializeForm()
        Me.mvBol_Close = False
        mvUrc_Caculator.txtInput.Text = "10"
        mod_Format.Sub_ShowControl(mvUrc_Caculator, 25)
    End Sub
#End Region
#Region "Form events"
    Private Sub frm_DiscountServiceVat_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Not mvBol_Close Then
            e.Cancel = True
        End If
    End Sub
    Private Sub frm_DiscountServiceVat_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        SubM_InitializeForm()
    End Sub
#End Region
#Region "Nút Confirm"
    Private Sub cmdConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConfirm.Click
        Try
            If Not IsNumeric(mvUrc_Caculator.txtInput.Text) Then
                FunG_Alert("Thông báo lỗi!", "Yêu cầu nhập số trong khoảng 1-100 !", frm_Alert.WTYPE.ERROR)
            Else
                If Convert.ToDouble(mvUrc_Caculator.txtInput.Text) < 0 Or Convert.ToDouble(mvUrc_Caculator.txtInput.Text) > 100 Then
                    FunG_Alert("Thông báo lỗi!", "Yêu cầu nhập số trong khoảng 1-100 !", frm_Alert.WTYPE.ERROR)
                Else
                    mvCls_SaleDetail.ID = Me.txtSoHD.Text
                    mvCls_SaleDetail.Price = mvUrc_Caculator.txtInput.Text
                    'Cập nhật lại thuế
                    If Me.gvStr_Type = "DISCOUNT" Then
                        mvCls_SaleDetailUpdate.FuncG_UpdateFeeBill(mvCls_SaleDetail, 1) 'Cập nhật giảm giá
                    ElseIf Me.gvStr_Type = "SERVICE" Then
                        mvCls_SaleDetailUpdate.FuncG_UpdateFeeBill(mvCls_SaleDetail, 2) 'Cập nhật phí dịch vụ
                    ElseIf Me.gvStr_Type = "VAT" Then
                        mvCls_SaleDetailUpdate.FuncG_UpdateFeeBill(mvCls_SaleDetail, 3) 'Cập nhật thuế VAT
                    End If
                    frm_Cash.SubM_InitializeForm()
                    mvUrc_Caculator.txtInput.Text = "10"
                    mvBol_Close = True
                    Me.Close()
                End If
            End If
        Catch ex As Exception

        End Try
    End Sub
#End Region
#Region "Nút exit"
    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        mvBol_Close = True
        Me.Close()
    End Sub
#End Region
End Class